﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.Workorders;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Sell.Api.Write.Application.Command.GoodCommand;

namespace Sell.Api.Write.Controllers.Goods
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GoodController : ControllerBase
    {
        public IMediator mediator { get;}
        public GoodController(IMediator _mediator)
        {
            mediator = _mediator;
        }
        /// <summary>
        /// 新增货品信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> GoodAdd(GoodAddCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除货品信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]   
        public async Task<ApiResult<int>> GoodDel([FromQuery]GoodDelCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改货品信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> GoodUpdate(GoodUpdateCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
